'awe poo you guys use a template file instead of creating everything on the fly.
'

#rem
Function newRPGfile (templatefile as String, newrpg as String) as integer
 newRPGfile = 0 ' default return value 0 means failure
 IF newrpg = "" THEN EXIT FUNCTION
 textcolor uilook(uiSelectedDisabled), 0
 printstr "Please Wait...", 0, 40, vpage
 printstr "Creating RPG File", 0, 50, vpage
 setvispage vpage
 IF NOT isfile(templatefile) THEN
  printstr "Error: ohrrpgce.new not found", 0, 60, vpage
  printstr "Press Enter to quit", 0, 70, vpage
  setvispage vpage
  waitforanykey
  EXIT FUNCTION
 END IF
 writeablecopyfile templatefile, newrpg
 printstr "Unlumping", 0, 60, vpage
 setvispage vpage 'refresh
 unlump newrpg, workingdir + SLASH
 '--create archinym information lump
 DIM fh as integer = FREEFILE
 OPEN workingdir + SLASH + "archinym.lmp" FOR OUTPUT AS #fh
 PRINT #fh, "ohrrpgce"
 PRINT #fh, version
 CLOSE #fh
 printstr "Finalumping", 0, 80, vpage
 setvispage vpage 'refresh
 '--re-lump files as NEW rpg file
 dolumpfiles newrpg
 newRPGfile = -1 'return true for success
END FUNCTION
#end